﻿<!--
	RegExpress
	
	Copyright (c) 2010, Daniel McGaughran
	
	Licensed under the Apache Licence, Version 2.0 (the "Licence");
	you may not use this file except in compliance with the Licence.
	You may obtain a copy of the License at
	
		http://www.apache.org/licenses/LICENSE-2.0
	
	Unless required by applicable law or agreed to in writing, software
	distributed under the Licence is distributed on an "AS IS" BASIS,
	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	See the Licence for the specific language governing permissions and
	limitations under the Licence.
	
	-->

<UserControl x:Class="RegExpress.UI.HostControls.ReplaceMatches"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:xrCt="clr-namespace:XrControls;assembly=XrControls">

    <Grid>
        <Grid.RowDefinitions>
			<RowDefinition Height="Auto" />
			<RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>

		<StackPanel Grid.ColumnSpan="2">
			<TextBlock Style="{StaticResource LabelText}" Text="Expression" />
			<Grid>
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="*" />
					<ColumnDefinition Width="Auto" />
				</Grid.ColumnDefinitions>

				<TextBox Text="{Binding Mode=TwoWay, Path=RegExpression, UpdateSourceTrigger=PropertyChanged}" />
				<Expander Grid.Column="1" Style="{DynamicResource PopupExpander}">
					<Expander.Header>
						<TextBlock Style="{StaticResource ButtonText}" Text="Options" />
					</Expander.Header>
					<Grid>
						<Grid.RowDefinitions>
							<RowDefinition />
							<RowDefinition />
							<RowDefinition />
							<RowDefinition />
						</Grid.RowDefinitions>

						<xrCt:ToggleSwitch Value="{Binding Path=IsCaseIgnored, Mode=TwoWay}">
							<TextBlock Style="{StaticResource SettingLabel}" Text="IgnoreCase" />
						</xrCt:ToggleSwitch>
						<xrCt:ToggleSwitch Grid.Row="1" Value="{Binding Path=IsWhitespaceIgnored, Mode=TwoWay}">
							<TextBlock Style="{StaticResource SettingLabel}" Text="IgnorePatternWhitespace" />
						</xrCt:ToggleSwitch>
						<xrCt:ToggleSwitch Grid.Row="2" Value="{Binding Path=IsNewlineMatchedByDot, Mode=TwoWay}">
							<TextBlock Style="{StaticResource SettingLabel}" Text="Singleline (Dot matches newline)" />
						</xrCt:ToggleSwitch>
						<xrCt:ToggleSwitch Grid.Row="3" Value="{Binding Path=IsMultiLine, Mode=TwoWay}">
							<TextBlock Style="{StaticResource SettingLabel}" Text="Multiline (^/$ operate per line)" />
						</xrCt:ToggleSwitch>
					</Grid>
				</Expander>
			</Grid>

			<TextBlock Style="{StaticResource LabelText}" Text="Replacement Expression" />
			<TextBox Style="{StaticResource EditorTextBox}"
					Text="{Binding Mode=TwoWay, Path=ReplacementExpression, UpdateSourceTrigger=PropertyChanged}" />

			<xrCt:UniformDoubleStack>
				<Button Command="{Binding PerformReplacementCmd}"
						xrCt:UniformDoubleStack.IsAtStackEnd="True">
					<TextBlock Style="{StaticResource ButtonText}" Text="Replace" />
				</Button>
			</xrCt:UniformDoubleStack>
		</StackPanel>


		<TextBlock Grid.Row="1" Style="{StaticResource LabelText}" Text="Input" />
		<xrCt:ToggleSwitch Grid.Row="1" Grid.Column="1" IsReadOnly="True"
					HorizontalAlignment="Stretch" VerticalAlignment="Center"
					IsEnabled="{Binding HasResult}" Value="{Binding HasMatch}">
			<TextBlock Style="{StaticResource LabelText}" Text="Output" />
		</xrCt:ToggleSwitch>
		
		<TextBox Grid.Row="2" Style="{StaticResource EditorTextBox}"
            Text="{Binding Mode=TwoWay, Path=Input, UpdateSourceTrigger=PropertyChanged}" />
        <TextBox Grid.Row="2" Grid.Column="1" Style="{StaticResource EditorTextBox}" IsReadOnly="True"
            Text="{Binding Mode=OneWay, Path=Output}" />
    </Grid>

</UserControl>
